package com.dianning.web.action.user;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.*;
import org.apache.struts2.interceptor.SessionAware;

import com.dianning.bean.ChannelContact;
import com.dianning.bean.Parameter;
import com.dianning.bean.Profile;
import com.dianning.bean.ProfileInfo;
import com.dianning.bean.ProfileLink;
import com.dianning.bean.Resume;
import com.dianning.bean.UserDetail;
import com.dianning.bean.UserInfo;
import com.dianning.bean.Visitor;
import com.dianning.comm.Constant;
import com.dianning.comm.DianningUtil;
import com.dianning.comm.OrderObj;
import com.dianning.comm.Util;
import com.dianning.service.ChannelService;
import com.dianning.service.InfoService;
import com.dianning.service.ParameterService;
import com.dianning.service.ProfileService;
import com.dianning.service.UserInfoService;
import com.dianning.service.VisitorService;
import com.dianning.service.web.PageList;
import com.dianning.service.web.Pages;
import com.dianning.web.action.BaseAction;
import com.dianning.web.interceptor.UserSessionAware;
import com.dianning.web.servlet.UserSession;
import com.dianning.web.ui.OptionsInt;
import com.dianning.web.ui.OptionsLong;
import com.dianning.web.ui.OptionsString;
import com.dianning.web.ui.RadioInt;
import com.dianning.web.ui.RadioLong;

public class ProfileAction extends BaseAction implements SessionAware,UserSessionAware{

	private static final Log logger = LogFactory.getLog(ProfileAction.class);
	
	private ProfileService profileService;
	private ChannelService channelService;

	public ProfileService getProfileService() {
		return profileService;
	}

	public void setProfileService(ProfileService profileService) {
		this.profileService = profileService;
	}

	public ChannelService getChannelService() {
		return channelService;
	}

	public void setChannelService(ChannelService channelService) {
		this.channelService = channelService;
	}
	
	private List smallChannelList = new ArrayList();
	private List areaList = new ArrayList();

	public List getSmallChannelList() {
		return smallChannelList;
	}

	public void setSmallChannelList(List smallChannelList) {
		this.smallChannelList = smallChannelList;
	}
	
	public List getAreaList() {
		return areaList;
	}

	public void setAreaList(List areaList) {
		this.areaList = areaList;
	}

	private void setBigChannelListValues(){
		List l = this.getChannelService().findChannelContacts(-1, 1, "orders", 0);
		for(int i=0;i<l.size();i++){
			ChannelContact cc = (ChannelContact) l.get(i);
			bigChannelList.add(new RadioLong(cc.getId(), cc.getChannel().getChannelName()));
		}
	}
	private void setSmallChannelListValues(long cid){
		if(cid==0){
			smallChannelList.add(new OptionsLong(0, "请选择"));
		}else{
			List l = this.getChannelService().findChannelContacts(cid, 2, "orders", 0);
			for(int i=0;i<l.size();i++){
				ChannelContact cc = (ChannelContact) l.get(i);
				smallChannelList.add(new OptionsLong(cc.getId(), cc.getChannel().getChannelName()));
			}
		}
	}
	private void setAreaListValues(){
		areaList.add(new OptionsString("全沈阳", "全沈阳"));
		areaList.add(new OptionsString("全鞍山", "全鞍山"));
	}
	
	private String name;		//网店名头
	private String area;		//区域
	private long cid;			//大类
	private long ccid;			//小类
	private String manage;		//经营
	private String companyname;	//公司名称
	private String linkman;		//联系人
	private String linktel;		//联系电话
	private String address;		//地址
	private String service;		//售后
	private String about;		//商家介绍
	private String key1;
	private String value1;
	private String key2;
	private String value2;
	private String key3;
	private String value3;
	private String key4;
	private String value4;
	private String webkey;		//网站名
	private int updatekey = 0;
	private List ccids = new ArrayList();		//类别列表
	private int style = 1;		//样式
	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getArea() {
		return area;
	}

	public void setArea(String area) {
		this.area = area;
	}

	public long getCid() {
		return cid;
	}

	public void setCid(long cid) {
		this.cid = cid;
	}

	public long getCcid() {
		return ccid;
	}

	public void setCcid(long ccid) {
		this.ccid = ccid;
	}

	public String getManage() {
		return manage;
	}

	public void setManage(String manage) {
		this.manage = manage;
	}

	public String getCompanyname() {
		return companyname;
	}

	public void setCompanyname(String companyname) {
		this.companyname = companyname;
	}

	public String getLinkman() {
		return linkman;
	}

	public void setLinkman(String linkman) {
		this.linkman = linkman;
	}

	public String getLinktel() {
		return linktel;
	}

	public void setLinktel(String linktel) {
		this.linktel = linktel;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getService() {
		return service;
	}

	public void setService(String service) {
		this.service = service;
	}

	public String getAbout() {
		return about;
	}

	public void setAbout(String about) {
		this.about = about;
	}

	public String getKey1() {
		return key1;
	}

	public void setKey1(String key1) {
		this.key1 = key1;
	}

	public String getValue1() {
		return value1;
	}

	public void setValue1(String value1) {
		this.value1 = value1;
	}

	public String getKey2() {
		return key2;
	}

	public void setKey2(String key2) {
		this.key2 = key2;
	}

	public String getValue2() {
		return value2;
	}

	public void setValue2(String value2) {
		this.value2 = value2;
	}

	public String getKey3() {
		return key3;
	}

	public void setKey3(String key3) {
		this.key3 = key3;
	}

	public String getValue3() {
		return value3;
	}

	public void setValue3(String value3) {
		this.value3 = value3;
	}

	public String getKey4() {
		return key4;
	}

	public void setKey4(String key4) {
		this.key4 = key4;
	}

	public String getValue4() {
		return value4;
	}

	public void setValue4(String value4) {
		this.value4 = value4;
	}

	public String getWebkey() {
		return webkey;
	}

	public void setWebkey(String webkey) {
		this.webkey = webkey;
	}

	public int getUpdatekey() {
		return updatekey;
	}

	public void setUpdatekey(int updatekey) {
		this.updatekey = updatekey;
	}

	public List getCcids() {
		return ccids;
	}

	public void setCcids(List ccids) {
		this.ccids = ccids;
	}

	public int getStyle() {
		return style;
	}

	public void setStyle(int style) {
		this.style = style;
	}	
	
	private List channels;
	private List bigChannelList;;
	private Profile profile;
	private String domain = Constant.DOMAIN;
	private String profileDomain = Constant.PROFILE_DOMAIN;
	private List infos;
	private long infonum = 0;
	private List aptitudes;
	private long aptitudenum = 0;
	private List abouts;
	private long aboutnum = 0;
	private List commons;
	private long commonnum = 0;
	private List links;
	private long linknum = 0;
	

	public List getChannels() {
		return channels;
	}

	public void setChannels(List channels) {
		this.channels = channels;
	}
	
	public List getBigChannelList() {
		return bigChannelList;
	}

	public void setBigChannelList(List bigChannelList) {
		this.bigChannelList = bigChannelList;
	}

	public List getInfos() {
		return infos;
	}

	public void setInfos(List infos) {
		this.infos = infos;
	}
	
	public Profile getProfile() {
		return profile;
	}

	public void setProfile(Profile profile) {
		this.profile = profile;
	}
	
	public String getDomain() {
		return domain;
	}

	public void setDomain(String domain) {
		this.domain = domain;
	}
	
	public String getProfileDomain() {
		return profileDomain;
	}

	public void setProfileDomain(String profileDomain) {
		this.profileDomain = profileDomain;
	}

	public long getInfonum() {
		return infonum;
	}


	public List getAptitudes() {
		return aptitudes;
	}

	public void setAptitudes(List aptitudes) {
		this.aptitudes = aptitudes;
	}

	public long getAptitudenum() {
		return aptitudenum;
	}

	public void setAptitudenum(long aptitudenum) {
		this.aptitudenum = aptitudenum;
	}

	public List getCommons() {
		return commons;
	}

	public void setCommons(List commons) {
		this.commons = commons;
	}

	public List getAbouts() {
		return abouts;
	}

	public void setAbouts(List abouts) {
		this.abouts = abouts;
	}

	public long getAboutnum() {
		return aboutnum;
	}

	public void setAboutnum(long aboutnum) {
		this.aboutnum = aboutnum;
	}

	public long getCommonnum() {
		return commonnum;
	}

	public void setCommonnum(long commonnum) {
		this.commonnum = commonnum;
	}
	
	public void setInfonum(long infonum) {
		this.infonum = infonum;
	}
	
	private UserSession userSession;
	private Map session;

	public UserSession getUserSession() {
		return userSession;
	}

	public void setUserSession(UserSession userSession) {
		this.userSession = userSession;
	}
	
	public Map getSession() {
		return session;
	}
	
	public void setSession(Map session) {
		this.session = session;
	}

	public List getLinks() {
		return links;
	}

	public void setLinks(List links) {
		this.links = links;
	}

	public long getLinknum() {
		return linknum;
	}

	public void setLinknum(long linknum) {
		this.linknum = linknum;
	}

	private long id;
	private String content;
	private List photo;
	private int photonum;
	private int orders;
	private String title;
	private String link;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public List getPhoto() {
		return photo;
	}

	public void setPhoto(List photo) {
		this.photo = photo;
	}

	public int getPhotonum() {
		return photonum;
	}

	public void setPhotonum(int photonum) {
		this.photonum = photonum;
	}

	public int getOrders() {
		return orders;
	}

	public void setOrders(int orders) {
		this.orders = orders;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getLink() {
		return link;
	}

	public void setLink(String link) {
		this.link = link;
	}

	public String execute() {
		try {
			return this.executeMethod(this.getAction());
		} catch (Exception e) {
			logger.error(e);
			return ERROR;
		}
	}
	
	public String index(){
		this.setAction("profileupdate");
		this.setProfile(this.getProfileService().findProfileByUid(userSession.getUid()));
		this.name = profile.getName();
		this.area = profile.getArea();
		this.cid = profile.getCid();
		this.ccid = profile.getCcid();
		this.manage = profile.getManage();
		this.companyname = profile.getCompanyname();
		this.linkman = profile.getLinkman();
		this.linktel = profile.getLinktel();
		this.address = profile.getAddress();
		this.service = profile.getService();
		this.about = profile.getAbout();
		this.key1 = profile.getKey1();
		this.value1 = profile.getValue1();
		this.key2 = profile.getKey2();
		this.value2 = profile.getValue2();
		this.key3 = profile.getKey3();
		this.value3 = profile.getValue3();
		this.key4 = profile.getKey4();
		this.value4 = profile.getValue4();
		this.webkey = profile.getWebkey();
		if(StringUtils.isBlank(this.webkey)){
			this.updatekey=1;
		}else{
			this.updatekey=0;
		}	
		setAreaListValues();
		this.setInfonum(this.getProfileService().getProfileInfoNum(userSession.getUid(),"info"));
		this.setInfos(this.getProfileService().findProfileInfos(userSession.getUid(),"info", "orders", 0));
		this.getSession().put("code", "");
		return "index";
	}
	
	public String profileupdate(){
		Profile p = this.getProfileService().findProfileByUid(userSession.getUid());
		if(this.updatekey==1){
			Profile kp = this.getProfileService().findProfileByWebkey(webkey);
			if(kp!=null){
				this.addActionError(this.getText("error.profile.webkey"));
				this.getSession().put("code", "webkey_error");
				this.setProfile(this.getProfileService().findProfileByUid(userSession.getUid()));
				this.setBigChannelList(this.getChannelService().findChannelContacts(-1, 1, "orders", 0));
				setSmallChannelListValues(this.cid);
				this.setChannels(this.getChannelService().findChannelContacts(-1, 2, "orders", 0));
				setAreaListValues();
				this.setInfonum(this.getProfileService().getProfileInfoNum(userSession.getUid(),"info"));
				this.setInfos(this.getProfileService().findProfileInfos(userSession.getUid(),"info", "orders", 0));
				return "index";
			}
		}
		p.setName(this.name);
		p.setArea(this.area);
		//p.setCid(this.cid);
		//p.setCcid(this.ccid);
		p.setManage(this.manage);
		p.setCompanyname(this.companyname);
		p.setLinkman(this.linkman);
		p.setLinktel(this.linktel);
		p.setAddress(this.address);
		p.setService(this.service);
		p.setAbout(this.about);
		p.setKey1(this.key1);
		p.setValue1(this.value1);
		p.setKey2(this.key2);
		p.setValue2(this.value2);
		p.setKey3(this.key3);
		p.setValue3(this.value3);
		p.setKey4(this.key4);
		p.setValue4(this.value4);
		p.setWebkey(this.webkey);
		if(this.updatekey==1){
			p.setShowstatus(2);
			this.getProfileService().updateProfile(p);
			return "autovip";
		}else{
			p.setShowstatus(2);
			this.getProfileService().updateProfile(p);
			this.addActionError(this.getText("error.profile.final"));
			this.getSession().put("code", "profile_final");
			this.setProfile(this.getProfileService().findProfileByUid(userSession.getUid()));
			setAreaListValues();
			this.setInfonum(this.getProfileService().getProfileInfoNum(userSession.getUid(),"info"));
			this.setInfos(this.getProfileService().findProfileInfos(userSession.getUid(),"info", "orders", 0));
			return "index";
		}
		
	}
	
	public String infoadd(){
		this.setAction("doinfoadd");
		this.setProfile(this.getProfileService().findProfileByUid(userSession.getUid()));
		return "infoadd";
	}
	
	public String doinfoadd(){
		Profile p = this.getProfileService().findProfileByUid(userSession.getUid());
		p.setShowstatus(2);
		this.getProfileService().updateProfile(p);
		ProfileInfo pi = new ProfileInfo();
		pi.setUid(userSession.getUid());
		pi.setContent(DianningUtil.filterKeyword(this.content));
		pi.setPhoto(this.photo);
		if(this.photo==null || this.photo.isEmpty()){
			pi.setPhotonum(0);
		}else{
			pi.setPhotonum(this.photo.size());
		}
		pi.setType("info");
		pi.setOrders(this.orders);
		pi.setAddTime(new Date());
		this.getProfileService().saveProfileInfo(pi);
		return "profile";
	}
	
	public String infoupdate(){
		this.setAction("doinfoupdate");
		this.setProfile(this.getProfileService().findProfileByUid(userSession.getUid()));
		ProfileInfo pi = this.getProfileService().findProfileInfoById(this.id);
		this.setContent(pi.getContent());
		this.setPhoto(pi.getPhoto());
		this.setPhotonum(pi.getPhotonum());
		this.setOrders(pi.getOrders());
		return "infoupdate";
	}
	
	public String doinfoupdate(){
		Profile p = this.getProfileService().findProfileByUid(userSession.getUid());
		p.setShowstatus(2);
		this.getProfileService().updateProfile(p);
		ProfileInfo pi = this.getProfileService().findProfileInfoById(this.id);
		pi.setContent(DianningUtil.filterKeyword(this.content));
		pi.setPhoto(this.photo);
		if(this.photo==null || this.photo.isEmpty()){
			pi.setPhotonum(0);
		}else{
			pi.setPhotonum(this.photo.size());
		}
		pi.setOrders(this.orders);
		pi.setAddTime(new Date());
		this.getProfileService().updateProfileInfo(pi);
		return "profile";
	}

	public String del(){
		ProfileInfo pi = this.getProfileService().findProfileInfoById(this.id);
		if(pi.getUid()==userSession.getUid()){
			this.getProfileService().removeProfileInfo(pi);
			Profile p = this.getProfileService().findProfileByUid(userSession.getUid());
			p.setShowstatus(2);
			this.getProfileService().updateProfile(p);
		}
		return "profile";
	}
	
	public String vipdel(){
		ProfileInfo pi = this.getProfileService().findProfileInfoById(this.id);
		if(pi.getUid()==userSession.getUid()){
			this.getProfileService().removeProfileInfo(pi);
			Profile p = this.getProfileService().findProfileByUid(userSession.getUid());
			p.setShowstatus(2);
			this.getProfileService().updateProfile(p);
		}
		return "govip";
	}
	
	public String dovip(){
		Profile p = this.getProfileService().findProfileByUid(userSession.getUid());
		p.setStatus(2);
		this.getProfileService().updateProfile(p);
		return "govip";
	}
	
	public String vip(){
		this.setAction("vipupdate");
		this.setProfile(this.getProfileService().findProfileByUid(userSession.getUid()));
		this.cid = profile.getCid();
		
		if(this.cid == 0){
			List l = this.getChannelService().findChannelContacts(-1, 1, "orders", 0);
			ChannelContact cc = (ChannelContact) l.get(0);
			this.cid = cc.getId();
		}
		this.ccid = profile.getCcid();
		
		this.setStyle(profile.getStyle());
		this.setBigChannelList(this.getChannelService().findChannelContacts(-1, 1, "orders", 0));
		setSmallChannelListValues(this.cid);
		this.setChannels(this.getChannelService().findChannelContacts(-1, 2, "orders", 0));
		
		this.setAptitudenum(this.getProfileService().getProfileInfoNum(userSession.getUid(),"aptitude"));
		this.setAptitudes(this.getProfileService().findProfileInfos(userSession.getUid(),"aptitude", "orders", 0));
		this.setCommonnum(this.getProfileService().getProfileInfoNum(userSession.getUid(),"common"));
		this.setCommons(this.getProfileService().findProfileInfos(userSession.getUid(),"common", "orders", 0));
		this.setAboutnum(this.getProfileService().getProfileInfoNum(userSession.getUid(),"about"));
		this.setAbouts(this.getProfileService().findProfileInfos(userSession.getUid(),"about", "orders", 0));
		this.setLinknum(this.getProfileService().getProfileLinkNum(userSession.getUid()));
		this.setLinks(this.getProfileService().findProfileLinks(userSession.getUid(), "orders", 0));
		this.getSession().put("code", "");
		return "vip";
	}
	
	public String vipupdate(){
		Profile p = this.getProfileService().findProfileByUid(userSession.getUid());
		p.setCid(this.cid);
		p.setCcid(this.ccid);
		p.setCcids(this.ccids);
		p.setStyle(this.style);
		p.setShowstatus(2);
		this.getProfileService().updateProfile(p);
		this.addActionError(this.getText("error.profile.final"));
		this.getSession().put("code", "profile_final");
		this.setProfile(this.getProfileService().findProfileByUid(userSession.getUid()));
		this.setBigChannelList(this.getChannelService().findChannelContacts(-1, 1, "orders", 0));
		setSmallChannelListValues(this.cid);
		this.setChannels(this.getChannelService().findChannelContacts(-1, 2, "orders", 0));
		this.setAptitudenum(this.getProfileService().getProfileInfoNum(userSession.getUid(),"aptitude"));
		this.setAptitudes(this.getProfileService().findProfileInfos(userSession.getUid(),"aptitude", "orders", 0));
		this.setCommonnum(this.getProfileService().getProfileInfoNum(userSession.getUid(),"common"));
		this.setCommons(this.getProfileService().findProfileInfos(userSession.getUid(),"common", "orders", 0));
		this.setLinknum(this.getProfileService().getProfileLinkNum(userSession.getUid()));
		this.setLinks(this.getProfileService().findProfileLinks(userSession.getUid(), "orders", 0));
		return "vip";
		
	}

	public String aptitudeadd(){
		this.setAction("doaptitudeadd");
		this.setProfile(this.getProfileService().findProfileByUid(userSession.getUid()));
		return "aptitudeadd";
	}
	
	public String doaptitudeadd(){
		Profile p = this.getProfileService().findProfileByUid(userSession.getUid());
		p.setShowstatus(2);
		this.getProfileService().updateProfile(p);
		ProfileInfo pi = new ProfileInfo();
		pi.setUid(userSession.getUid());
		pi.setContent(DianningUtil.filterKeyword(this.content));
		pi.setPhoto(this.photo);
		if(this.photo==null || this.photo.isEmpty()){
			pi.setPhotonum(0);
		}else{
			pi.setPhotonum(this.photo.size());
		}
		pi.setType("aptitude");
		pi.setOrders(this.orders);
		pi.setAddTime(new Date());
		this.getProfileService().saveProfileInfo(pi);
		return "govip";
	}
	
	public String aptitudeupdate(){
		this.setAction("doaptitudeupdate");
		this.setProfile(this.getProfileService().findProfileByUid(userSession.getUid()));
		ProfileInfo pi = this.getProfileService().findProfileInfoById(this.id);
		this.setContent(pi.getContent());
		this.setPhoto(pi.getPhoto());
		this.setPhotonum(pi.getPhotonum());
		this.setOrders(pi.getOrders());
		return "aptitudeupdate";
	}
	
	public String doaptitudeupdate(){
		Profile p = this.getProfileService().findProfileByUid(userSession.getUid());
		p.setShowstatus(2);
		this.getProfileService().updateProfile(p);
		ProfileInfo pi = this.getProfileService().findProfileInfoById(this.id);
		pi.setContent(DianningUtil.filterKeyword(this.content));
		pi.setPhoto(this.photo);
		if(this.photo==null || this.photo.isEmpty()){
			pi.setPhotonum(0);
		}else{
			pi.setPhotonum(this.photo.size());
		}
		pi.setOrders(this.orders);
		pi.setAddTime(new Date());
		this.getProfileService().updateProfileInfo(pi);
		return "govip";
	}

	public String commonadd(){
		this.setAction("docommonadd");
		this.setProfile(this.getProfileService().findProfileByUid(userSession.getUid()));
		return "commonadd";
	}
	
	public String docommonadd(){
		Profile p = this.getProfileService().findProfileByUid(userSession.getUid());
		p.setShowstatus(2);
		this.getProfileService().updateProfile(p);
		ProfileInfo pi = new ProfileInfo();
		pi.setUid(userSession.getUid());
		pi.setContent(DianningUtil.filterKeyword(this.content));
		pi.setPhoto(this.photo);
		if(this.photo==null || this.photo.isEmpty()){
			pi.setPhotonum(0);
		}else{
			pi.setPhotonum(this.photo.size());
		}
		pi.setType("common");
		pi.setOrders(this.orders);
		pi.setAddTime(new Date());
		this.getProfileService().saveProfileInfo(pi);
		return "govip";
	}
	
	public String commonupdate(){
		this.setAction("docommonupdate");
		this.setProfile(this.getProfileService().findProfileByUid(userSession.getUid()));
		ProfileInfo pi = this.getProfileService().findProfileInfoById(this.id);
		this.setContent(pi.getContent());
		this.setPhoto(pi.getPhoto());
		this.setPhotonum(pi.getPhotonum());
		this.setOrders(pi.getOrders());
		return "commonupdate";
	}
	
	public String docommonupdate(){
		Profile p = this.getProfileService().findProfileByUid(userSession.getUid());
		p.setShowstatus(2);
		this.getProfileService().updateProfile(p);
		ProfileInfo pi = this.getProfileService().findProfileInfoById(this.id);
		pi.setContent(DianningUtil.filterKeyword(this.content));
		pi.setPhoto(this.photo);
		if(this.photo==null || this.photo.isEmpty()){
			pi.setPhotonum(0);
		}else{
			pi.setPhotonum(this.photo.size());
		}
		pi.setOrders(this.orders);
		pi.setAddTime(new Date());
		this.getProfileService().updateProfileInfo(pi);
		return "govip";
	}
	
	public String aboutadd(){
		this.setAction("doaboutadd");
		this.setProfile(this.getProfileService().findProfileByUid(userSession.getUid()));
		return "aboutadd";
	}
	
	public String doaboutadd(){
		Profile p = this.getProfileService().findProfileByUid(userSession.getUid());
		p.setShowstatus(2);
		this.getProfileService().updateProfile(p);
		ProfileInfo pi = new ProfileInfo();
		pi.setUid(userSession.getUid());
		pi.setContent(DianningUtil.filterKeyword(this.content));
		pi.setPhoto(this.photo);
		if(this.photo==null || this.photo.isEmpty()){
			pi.setPhotonum(0);
		}else{
			pi.setPhotonum(this.photo.size());
		}
		pi.setType("about");
		pi.setOrders(1);
		pi.setAddTime(new Date());
		this.getProfileService().saveProfileInfo(pi);
		return "govip";
	}
	
	public String aboutupdate(){
		this.setAction("doaboutupdate");
		this.setProfile(this.getProfileService().findProfileByUid(userSession.getUid()));
		ProfileInfo pi = this.getProfileService().findProfileInfoById(this.id);
		this.setContent(pi.getContent());
		this.setPhoto(pi.getPhoto());
		this.setPhotonum(pi.getPhotonum());
		this.setOrders(pi.getOrders());
		return "aboutupdate";
	}
	
	public String doaboutupdate(){
		Profile p = this.getProfileService().findProfileByUid(userSession.getUid());
		p.setShowstatus(2);
		this.getProfileService().updateProfile(p);
		ProfileInfo pi = this.getProfileService().findProfileInfoById(this.id);
		pi.setContent(DianningUtil.filterKeyword(this.content));
		pi.setPhoto(this.photo);
		if(this.photo==null || this.photo.isEmpty()){
			pi.setPhotonum(0);
		}else{
			pi.setPhotonum(this.photo.size());
		}
		pi.setOrders(1);
		pi.setAddTime(new Date());
		this.getProfileService().updateProfileInfo(pi);
		return "govip";
	}

	public String linkadd(){
		this.setAction("dolinkadd");
		this.setProfile(this.getProfileService().findProfileByUid(userSession.getUid()));
		return "linkadd";
	}
	
	public String dolinkadd(){
		Profile p = this.getProfileService().findProfileByUid(userSession.getUid());
		p.setShowstatus(2);
		this.getProfileService().updateProfile(p);
		ProfileLink pl = new ProfileLink();
		pl.setUid(userSession.getUid());
		pl.setTitle(this.title);
		pl.setLink(this.link);
		pl.setOrders(this.orders);
		pl.setAddTime(new Date());
		this.getProfileService().saveProfileLink(pl);
		return "govip";
	}
	
	public String linkupdate(){
		this.setAction("dolinkupdate");
		this.setProfile(this.getProfileService().findProfileByUid(userSession.getUid()));
		ProfileLink pl = this.getProfileService().findProfileLinkById(this.id);
		this.setTitle(pl.getTitle());
		this.setLink(pl.getLink());
		this.setOrders(pl.getOrders());
		return "linkupdate";
	}
	
	public String dolinkupdate(){
		Profile p = this.getProfileService().findProfileByUid(userSession.getUid());
		p.setShowstatus(2);
		this.getProfileService().updateProfile(p);
		ProfileLink pl = this.getProfileService().findProfileLinkById(this.id);
		pl.setTitle(this.title);
		pl.setLink(this.link);
		pl.setOrders(this.orders);
		pl.setAddTime(new Date());
		this.getProfileService().updateProfileLink(pl);
		return "govip";
	}
	
	public String linkdel(){
		ProfileLink pl = this.getProfileService().findProfileLinkById(this.id);
		if(pl.getUid()==userSession.getUid()){
			this.getProfileService().removeProfileLink(pl);
			Profile p = this.getProfileService().findProfileByUid(userSession.getUid());
			p.setShowstatus(2);
			this.getProfileService().updateProfile(p);
		}
		return "govip";
	}

	
}
